﻿
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 
<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
	<script src="../../js/vue.js"></script>
	<script src="../../js/jquery/jquery-1.5.2.min.js"></script>
<script src="script/common.js"></script>
<script src="script/validate.js"></script>
</head>
  <script type="text/javascript">
  	
  		function myAdd(){
  			document.sysUserForm.submit();
  		}
  </script>
  <body>
  <div id="app">
    <div class="page_title">权限管理 > 用户管理 > 指派用户角色</div>
    <form name="sysUserForm" method="post" action="/CRM/sysUser.do">
    	<input type="hidden" name="method" value="dispatchSysRole">
    	<div class="button_bar">
	   		<button class="common_button" onclick="help('');">帮助</button>
	   		<button class="common_button" onclick="back();">返回</button>
			<button class="common_button" @click="up" type="button">保存</button>
	   	</div>
	   	<table class="query_form_table" v-for="s in sum">
	   		<tr>
			<tr>
				<th>编号</th>
				<td v-text="s.usr_id" id="bh"></td>
				<th>用户名</th>
				<td v-text="s.usr_name"></td>
			</tr>
	   		</tr>
	   		<tr>
	   			<th>
	   				角色
	   			</th>
	   			<td>
	   				<select id="js"><option v-if="s.role_name!=''" value="" v-text="s.role_name"></option>
						<option v-if="s.role_name==''" value="0">未指派</option>

	   					<option value="1" selected="selected">管理员</option>
<option value="3">销售主管</option>
<option value="4">客户经理</option>
<option value="5">高管</option>
<option value="9">销售员</option>
<option value="0">未分配</option></select>
	   			</td>
	   			<th>
	   				状态
	   			</th>
				<td class="list_data_text" v-if="s.usr_flag==1">
					正常
				</td>
				<td class="list_data_text" v-if="s.usr_flag==2">
					禁用
				</td>
	   		</tr>
	   	</table>
    </form>
  </div>
  </body>
<script>
	const  app=new Vue({
		el:"#app",
		data:{
			sum:[],
			sums:{
				usr_id:"",
			},
		},methods: {
			load() {
				$.getJSON("/SysUser/queryPages", this.sums, json => {
					this.pageInfo = json.data.pageInfo;
					this.sum = json.data.pageInfo.list;
				});
			}
			,
			up() {
				let bh = $("#bh").text();
				let js = $("#js").val();
				$.post("/SysUser/update", {"usr_id": bh, "usr_role_id": js}, json => {
					if (json.message == "OK") {
						alert("保存成功");
						location.href = "list.html";
					} else {
						alert("保存成功");
						location.href = "list.html";
					}
				})


			}
		},mounted(){
			let ser=new URLSearchParams(location.search).get("usr_id");
			this.sums.usr_id=ser;

			this.load();
		}
	});
</script>
</html>
 
